################################################################# 
## Title: Birthday Block for Smartor's ezPortal
## Author: Smartor <smartor_xp@hotmail.com> - http://smartor.is-root.com
## Description: This file explains you how to create Birthday block on ezPortal
##		Required Birthday MOD
##
## Files To Edit: 2
##	portal.php
##	templates/subSilver/portal_body.tpl
##
## Included Files: N/A
##
################################################################# 

#
#-----[ OPEN ]---------------------------------------------
#
portal.php

#
#-----[ FIND ]----------------------------------------
#
//
// Start output of page


#
#-----[ BEFORE ADD ]-----------------------------------
#
// Birthday Mod, Show users with birthday 
$sql = "SELECT user_id, username, user_birthday,user_level FROM " . USERS_TABLE. " WHERE user_birthday!=999999 ORDER BY username";
if($result = $db->sql_query($sql))
{
$birthdayrow = $db->sql_fetchrowset($result);
if (!empty($birthdayrow))
{
	$year=create_date('Y', time(), $board_config['board_timezone']);
	$date_today = create_date('Ymd', time(), $board_config['board_timezone']);
	$date_forward = create_date('Ymd', time()+($board_config['birthday_check_day']*86400), $board_config['board_timezone']);
	for($i = 0; $i < count($birthdayrow); $i++)
	{
		$user_birthday=realdate("md",$birthdayrow[$i]['user_birthday']);
		$user_birthday2=(($year.$user_birthday<$date_today)? $year+1:$year).$user_birthday;
		if ($user_birthday2==$date_today)
		{
			//user have birthday today
			$user_age=$year- realdate ('Y',$birthdayrow[$i]['user_birthday']); 
			$style_color = ($birthdayrow[$i]['user_level'] == ADMIN )?'style="color:#' . $theme['fontcolor3'] . '"':(( $birthdayrow[$i]['user_level'] == MOD )?'style="color:#' . $theme['fontcolor2'] . '"':''); 
			$birthday_today_list .= ' <a href="' . append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=" . $birthdayrow[$i]['user_id']) . '"' . $style_color .'><b>' . $birthdayrow[$i]['username'] . ' ('.$user_age.')</b></a>'; 
		}
		else if ($user_birthday2>$date_today  && $user_birthday2<=$date_forward)
		{
			// user are having birthday within the next days
			$user_age=($year.$user_birthday<$date_today)?$year- realdate('Y',$birthdayrow[$i]['user_birthday']) + 1 : $year- realdate('Y',$birthdayrow[$i]['user_birthday']); 
			$style_color = ($birthdayrow[$i]['user_level'] == ADMIN )?'style="color:#' . $theme['fontcolor3'] . '"':(( $birthdayrow[$i]['user_level'] == MOD )?'style="color:#' . $theme['fontcolor2'] . '"':'');
			$birthday_week_list .= ' <a href="' . append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=" . $birthdayrow[$i]['user_id']) . '"' . $style_color .'><b>' . $birthdayrow[$i]['username'] . ' ('.$user_age.')</b></a>';
		}
	}
}
}
$db->sql_freeresult($result);

#
#-----[ FIND ]----------------------------------------
#
	'L_VOTE_BUTTON' => $lang['Vote'],

#
#-----[ AFTER ADD ]-----------------------------------
#
	// Birthday Mod
	'L_WHOSBIRTHDAY_WEEK' => sprintf((($birthday_week_list)? $lang ['Birthday_week'].$birthday_week_list:$lang ['Nobirthday_week']),$board_config['birthday_check_day']),
	'L_WHOSBIRTHDAY_TODAY' =>($birthday_today_list&&$board_config['birthday_check_day'])? $lang ['Birthday_today'].$birthday_today_list:$lang ['Nobirthday_today'],
	'L_BIRTHDAY' => $lang['Birthday'],


#
#-----[ OPEN ]---------------------------------------------
#
templates/subSilver/portal_body.tpl

#
#-----[ FIND ]----------------------------------------
#
		  <table width="100%" cellpadding="2" cellspacing="1" border="0" class="forumline">
		   <tr>
			<td class="catHead" height="25"><span class="genmed"><b>{L_STATISTICS}</b></span></td>
		   </tr>
		   <tr>
			<td class="row1" align="left"><span class="gensmall">{TOTAL_USERS}<br />{NEWEST_USER}<br /><br/>{TOTAL_POSTS} {TOTAL_TOPICS}<br />&nbsp;</span></td>
		   </tr>
		  </table>
		  
		  <br />

#
#-----[ AFTER ADD ]-----------------------------------
#
		  <table width="100%" cellpadding="2" cellspacing="1" border="0" class="forumline">
		   <tr>
			<td class="catHead" height="25"><span class="genmed"><b>{L_BIRTHDAY}</b></span></td>
		   </tr>
		   <tr>
			<td class="row1" align="left"><span class="gensmall">{L_WHOSBIRTHDAY_TODAY}<br /><br />{L_WHOSBIRTHDAY_WEEK}<br />&nbsp;</span></td>
		   </tr>
		  </table>
		  
		  <br />

#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------ 
#
# EoF